package com.zjw.kaos.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zjw.kaos.common.AjaxResult;
import com.zjw.kaos.common.ResultUtils;
import com.zjw.kaos.pojo.DateRedcord;
import com.zjw.kaos.pojo.TransactionRecord;
import com.zjw.kaos.service.RecordService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/record")
public class RecordController {

    @Resource
    private RecordService recordService;

    @RequestMapping("/recordList")
    public @ResponseBody
    AjaxResult<PageInfo<TransactionRecord>> recordList(DateRedcord dateRedcord , @RequestParam(defaultValue = "1") Integer pageNum){
            PageHelper.startPage(pageNum,2);
            PageInfo pageInfo = new PageInfo<>(recordService.getRecordByTransactionDate(dateRedcord));
            System.out.println(pageInfo);
            return pageInfo.getSize() > 0 ? ResultUtils.sendSuccess(pageInfo) : ResultUtils.sendError("4044" , "此时间范围内没有交易");
//        return ResultUtils.sendSuccess(new PageInfo<>(recordService.getRecordByTransactionDate(dateRedcord)));
    }


}
